<template>
  <div class="mainDiv">
    <div class="content">
        <mt-cell  class="userInfo">
          <mt-button size="small" type="primary" v-show="!isWechat" @click="logout">退出</mt-button>
          <span slot="title" class="userTitle">
            <div class="username">{{userInfo.username}}</div>
            <div class="level">{{userInfo.vip_level==1?'VIP会员':'普通会员'}}</div>
          </span>
          <img slot="icon" v-bind:src="require('../assets/icons/学生.png')" width="64" height="64">
        </mt-cell>
          <div class="line"></div>
      <mt-cell :title="cell.title" v-for="cell in cells" v-show="!cell.vip||userInfo.vip_level!=1" class="split" is-link :to="cell.url">
        <span>{{cell.value}}</span>
      </mt-cell>
    </div>
  </div>
</template>

<script>
    export default {
        name: "UserCenter",
      data() {
        return {userInfo:{},
         cells:
           /*{title:"专家预约",value:"专家预约",url:"/login/order"},*/
            [{title:"开通VIP",value:"开通VIP",url:"/login/vip",vip:1},
            {title:"高考分数",value:"高考分数",url:"/student/score"},
            {title:"修改密码",value:"修改密码",url:"/login/modifyPassword"},
            {title:"修改手机绑定",value:"修改手机绑定",url:"/login/changePhone"},
            {title:"使用协议",value:"使用协议",url:"/login/xieyi"}]
        }
      },
      computed:{
        isWechat:function(){return isWechat()}
      },
      methods:{
        logout:function(){
          this.$http.post("/wx/logout").then((resp)=>{
              this.$root.userInfo = {};
              this.$router.push({path:"/login/login"})
          })
        }
      },
      created(){
        checkLogin(this);
      }
    }
</script>
<style>
  .userInfo .mint-cell-wrapper{
    padding: 30px;
  }
</style>
<style scoped>
  .userInfo{
    margin-bottom: 20px;
  }

  .userTitle{
    display: inline-block;
    vertical-align: middle;
  }
  .username{
    font-size: 18px;
    line-height: 30px;
  }
  .level{
    color:#51CDB7;
  }
  .split{
    margin-bottom: 5px;
  }
</style>
